from flask import Blueprint, request, jsonify
from app.services import PlanConfigService

bp = Blueprint('plan_configs', __name__)

@bp.route('/<int:user_id>', methods=['GET'])
def get_config(user_id):
    """获取学习计划配置"""
    result = PlanConfigService.get_config(user_id)
    return jsonify(result), result['code']

@bp.route('/<int:config_id>', methods=['DELETE'])
def delete_config(config_id):
    """删除学习计划配置"""
    result = PlanConfigService.delete_config(config_id)
    return jsonify(result), result['code']

@bp.route('/<int:config_id>', methods=['PUT'])
def update_config(config_id):
    """更新学习计划配置"""
    result = PlanConfigService.update_config(config_id, **request.get_json())
    return jsonify(result), result['code']